<?php
	/*
	 * File: remove_inc.php
	 * Last modification: 21.07.2011
	 * Author(s): kivio.wanderley
	 * 
	 */
?>

<?php /** UPPER PHP CODE */
	# Requires
	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
	require_once($t_core_dir . 'core_api.php');

	# Try to make the connection
	if( !datab_is_connected() ) {
		config_get_global_array();
		datab_connect( config_get('host'), (int)config_get('port'), config_get('database'), 
					   config_get('user'), config_get('password') );
		config_unset();						   
	}
	
	# Start session
	if( ! isset($_SESSION) ) session_start();
	
	$t_type = gpc_get_string('remove_type');
	$t_type_id = gpc_get_int('type_id');

?>
	
<?php /** CENTER PHP CODE */
	if( $t_type == 'people') { # For people 
		$t_query = "DELETE FROM tb_usuario
					WHERE id = $t_type_id;";
		$t_row = datab_query($t_query);	
		
		if(is_string($t_row)) { set_info_msg($t_row, I_ERR); }

	} elseif ( $t_type == 'user' ) { # For user 
		$t_query = "DELETE FROM tb_login
					WHERE usuario_id = $t_type_id;";
		$t_row = datab_query($t_query);	
		
		if(is_string($t_row)) { set_info_msg($t_row, I_ERR); }
		
	} elseif ( $t_type == ACCESS_DENIED ) {
		set_info_msg("ACCESS_DENIED", I_WARN);
		
	} else {
		set_info_msg("NO TYPE FOUNDED", I_ERR);
	}
	
	set_info_msg("REMOVE SUCCESS", I_OK, config_get('uri_prefix')."main_page.php?page=update_page&type_option_list=".$t_type);
?>